<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">订单类型</label>
        <el-select v-model="query.orderType" style="width: 185px;" clearable  placeholder="请选择订单类型" class="filter-item" @keyup.enter.native="crud.toQuery">
          <el-option
            v-for="item in orderOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
        <label class="el-form-item-label">电话</label>
        <el-input v-model="query.phone" clearable placeholder="电话" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <!--      <label class="el-form-item-label">小区</label>-->
        <!--      <el-select v-model="query.xqId" style="width: 185px;" placeholder="请选择小区" class="filter-item" @keyup.enter.native="crud.toQuery">-->
        <!--        <el-option-->
        <!--          v-for="item in xqOptions"-->
        <!--          :key="item.value"-->
        <!--          :label="item.label"-->
        <!--          :value="item.value">-->
        <!--        </el-option>-->
        <!--      </el-select>-->
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="phone" label="收款人电话" />
        <el-table-column prop="outDetailNo" label="商家明细单号" />
        <el-table-column prop="transferAmount" label="转账金额（元）">
          <template slot-scope="scope">
            <!-- 根据不同的值显示不同的内容 -->
            <span>{{scope.row.transferAmount/100}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="orderType" label="订单类型">
          <template slot-scope="scope">
            <!-- 根据不同的值显示不同的内容 -->
            <span v-if="scope.row.orderType === 1">儿童管理</span>
            <span v-else-if="scope.row.orderType === 2">跑腿服务</span>
            <span v-else-if="scope.row.orderType === 4">家政服务</span>
            <span v-else-if="scope.row.orderType === 5">看护预约</span>
            <span v-else-if="scope.row.orderType === 6">维修服务</span>
            <span v-else-if="scope.row.orderType === 7">团购预约</span>
            <span v-else />
          </template>
        </el-table-column>
        <el-table-column prop="transferRemark" label="转账备注" />
        <el-table-column prop="nickName" label="收款用户姓名" />
        <el-table-column prop="failReason" label="明细失败原因" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column prop="remark" label="备注信息" />
<!--        <el-table-column v-if="checkPer(['admin','payTransferDetail:del'])" label="操作" width="150px" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <udOperation-->
<!--              :data="scope.row"-->
<!--              :permission="permission"-->
<!--            />-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudPayTransferDetail from '@/api/system/payTransferDetail'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { tDetailId: null, detailId: null, outDetailNo: null, transferAmount: null, transferRemark: null, openid: null, userName: null, detailStatus: null, failReason: null, transferId: null, createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null }
export default {
  name: 'PayTransferDetail',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: 'payTransferDetailController', url: 'api/payTransferDetail', idField: 'tDetailId', sort: 'tDetailId,desc', crudMethod: { ...crudPayTransferDetail }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'payTransferDetail:add'],
        edit: ['admin', 'payTransferDetail:edit'],
        del: ['admin', 'payTransferDetail:del']
      },
      rules: {
        outDetailNo: [
          { required: true, message: '商家明细单号不能为空', trigger: 'blur' }
        ],
        transferAmount: [
          { required: true, message: '转账金额不能为空', trigger: 'blur' }
        ],
        transferRemark: [
          { required: true, message: '转账备注不能为空', trigger: 'blur' }
        ],
        openid: [
          { required: true, message: '收款用户openid不能为空', trigger: 'blur' }
        ],
        detailStatus: [
          { required: true, message: '明细状态不能为空', trigger: 'blur' }
        ]
      },
      orderOptions: [
        {
          value: 1,
          label: '儿童管理'
        }, {
          value: 2,
          label: '跑腿服务'
        }, {
          value: 4,
          label: '家政服务'
        }, {
          value: 5,
          label: '看护预约'
        }, {
          value: 6,
          label: '维修服务'
        }, {
          value: 7,
          label: '团购预约'
        }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      this.crud.optShow.add = false
      this.crud.optShow.edit = false
      this.crud.optShow.del = false
      this.crud.optShow.download = false
      console.log()
      return true
    }
  }
}
</script>

<style scoped>

</style>
